package com.ruoyi.gwc.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SnowFlakeIDGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.gwc.mapper.TDispatchVehiclesMapper;
import com.ruoyi.gwc.domain.TDispatchVehicles;
import com.ruoyi.gwc.service.ITDispatchVehiclesService;

import static com.ruoyi.common.utils.SecurityUtils.getUsername;

/**
 * 调度车辆Service业务层处理
 * 
 * @author wp
 * @date 2024-12-13
 */
@Service
public class TDispatchVehiclesServiceImpl extends ServiceImpl<TDispatchVehiclesMapper, TDispatchVehicles> implements ITDispatchVehiclesService
{
    @Autowired
    private TDispatchVehiclesMapper tDispatchVehiclesMapper;

    /**
     * 查询调度车辆
     * 
     * @param dispatchId 调度车辆主键
     * @return 调度车辆
     */
    @Override
    public TDispatchVehicles selectTDispatchVehiclesByDispatchId(Long dispatchId)
    {
        return tDispatchVehiclesMapper.selectTDispatchVehiclesByDispatchId(dispatchId);
    }

    /**
     * 查询调度车辆列表
     * 
     * @param tDispatchVehicles 调度车辆
     * @return 调度车辆
     */
    @Override
    public List<TDispatchVehicles> selectTDispatchVehiclesList(TDispatchVehicles tDispatchVehicles)
    {
        return tDispatchVehiclesMapper.selectTDispatchVehiclesList(tDispatchVehicles);
    }

    /**
     * 新增调度车辆
     * 
     * @param tDispatchVehicles 调度车辆
     * @return 结果
     */
    @Override
    public int insertTDispatchVehicles(TDispatchVehicles tDispatchVehicles)
    {
        tDispatchVehicles.setCreateTime(DateUtils.getNowDate());
        tDispatchVehicles.setCreateBy(getUsername());
        tDispatchVehicles.setDispatchId(SnowFlakeIDGenerator.getInstance().nextId());
        return tDispatchVehiclesMapper.insertTDispatchVehicles(tDispatchVehicles);
    }

    /**
     * 修改调度车辆
     * 
     * @param tDispatchVehicles 调度车辆
     * @return 结果
     */
    @Override
    public int updateTDispatchVehicles(TDispatchVehicles tDispatchVehicles)
    {
        tDispatchVehicles.setCreateTime(DateUtils.getNowDate());
        tDispatchVehicles.setCreateBy(getUsername());
        return tDispatchVehiclesMapper.updateTDispatchVehicles(tDispatchVehicles);
    }

    @Override
    public int updateTDispatchVehiclesByApplyId(TDispatchVehicles tDispatchVehicles)
    {
        return tDispatchVehiclesMapper.updateTDispatchVehiclesByApplyId(tDispatchVehicles);
    }



    /**
     * 批量删除调度车辆
     * 
     * @param dispatchIds 需要删除的调度车辆主键
     * @return 结果
     */
    @Override
    public int deleteTDispatchVehiclesByDispatchIds(Long[] dispatchIds)
    {
        return tDispatchVehiclesMapper.deleteTDispatchVehiclesByDispatchIds(dispatchIds);
    }

    /**
     * 删除调度车辆信息
     * 
     * @param dispatchId 调度车辆主键
     * @return 结果
     */
    @Override
    public int deleteTDispatchVehiclesByDispatchId(Long dispatchId)
    {
        return tDispatchVehiclesMapper.deleteTDispatchVehiclesByDispatchId(dispatchId);
    }
}
